﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WodLib;
//for editor
using System.Drawing.Design;
using System.Windows.Forms.Design;

namespace WodLib.Controls
{
    public class InventoryEditor : UITypeEditor
    {
        public override UITypeEditorEditStyle GetEditStyle(System.ComponentModel.ITypeDescriptorContext context)
        {
            return UITypeEditorEditStyle.Modal;
        }

        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            //end if is ont HumanInventory
            if (!(value is WodLib.HumanInventory))
                return value;

            IWindowsFormsEditorService editorService = (IWindowsFormsEditorService)
                provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService));

            //check is service was get
            if (editorService != null)
            {
                //create form
                InventoryEditorForm editor = new InventoryEditorForm((HumanInventory)value);
                editorService.ShowDialog(editor);
            }

            return value;
        }
    }
}
